# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/21 17:12
# @Author   : Robot-Zsj
"""
description:

i:
11 8 20
10 13 7

o:
1 # 最优结果只有一种
"""

a = list(map(int, input().split()))
b = list(map(int, input().split()))

maxBiggerCount = 0
ans = 0


def dfs(level, used, biggerCount):
    global maxBiggerCount, ans

    if level >= len(a):
        if biggerCount > maxBiggerCount:
            maxBiggerCount = biggerCount
            ans = 1
        elif biggerCount == maxBiggerCount:
            ans += 1
        return

    for i in range(len(a)):
        if used[i]:
            continue

        if i > 0 and a[i] == a[i - 1] and not used[i - 1]:
            continue

        used[i] = True
        dfs(level + 1, used, biggerCount + (1 if a[i] > b[level] else 0))
        used[i] = False


a.sort()
dfs(0, [False] * len(a), 0)
print(ans)
